﻿<%@ Page Title="Translation Maintenance &raquo; ResourceBlender" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="DuplicateTranslations.aspx.cs" Inherits="DuplicateTranslations" EnableEventValidation="false" %>
<%@ MasterType VirtualPath="~/MasterPage.master" %>

<asp:Content ID="cntHead" ContentPlaceHolderID="head" Runat="Server">
    <link rel="Stylesheet" type="text/css" href="css/spreadsheet.css" />
    <!--[if IE]>
    <link rel="Stylesheet" type="text/css" href="css/ie-spreadsheet.css" />
    <![endif]-->
</asp:Content>
<asp:Content ID="cntMain" ContentPlaceHolderID="cntMain" Runat="Server">
    <asp:ScriptManager ID="scrUpdateLanguages" runat="server"></asp:ScriptManager>
    <h1><asp:Label ID="lblDuplicatesHeading" runat="server" Text="Duplicate Translations"></asp:Label></h1>
    <div class="breadcrumbs">
        <asp:HyperLink ID="lnkNavHome" runat="server" NavigateUrl="~/Default.aspx">ResourceBlender</asp:HyperLink> &gt; <asp:HyperLink ID="lnkNavTranslations" runat="server" NavigateUrl="~/Translations.aspx">Translations</asp:HyperLink> &gt; Duplicate Translations
    </div>
    <asp:MultiView ID="mltMain" runat="server" ActiveViewIndex="0">
        <asp:View ID="viwFindDuplicatesForm" runat="server">
            <asp:SqlDataSource ID="dsTranslations" runat="server"
                 ConnectionString="<%$ ConnectionStrings:Default %>"
                 ProviderName="<%$ ConnectionStrings:Default.ProviderName %>"
                 OnSelected="dsTranslations_Selected">
            </asp:SqlDataSource>
            <div class="niceform">
                <fieldset>
                    <legend>Find Duplicates</legend>
                    <div class="formrow block">
                        <asp:UpdatePanel ID="updRadLanguage" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <div class="formrow block">
                                    <label class="block">Language</label>
                                    <asp:RadioButtonList ID="radLanguage" runat="server" RepeatLayout="Flow" 
                                        OnSelectedIndexChanged="SelectLanguage"
                                        AppendDataBoundItems="true"
                                        AutoPostBack="True" CssClass="checks applicationChecks plain" RepeatColumns="3">
                                        <asp:ListItem Text="All languages" Value="all"></asp:ListItem>
                                    </asp:RadioButtonList>
                                </div>
                                <asp:UpdateProgress ID="prgRadLanguage" runat="server" 
                                    AssociatedUpdatePanelID="updRadLanguage" 
                                    DisplayAfter="100">
                                    <ProgressTemplate>
                                        <div class="centered"><asp:Image ID="imgLoadingLanguagesSelection" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Finding Duplicates..." /></div>
                                    </ProgressTemplate>
                                </asp:UpdateProgress>
                                <h3><asp:Label ID="lblNumDuplicates" runat="server" Text="Find Duplicates"></asp:Label></h3>
                                <asp:GridView ID="grdFindDuplicates" runat="server" AllowPaging="True" 
                                    AllowSorting="True" AutoGenerateColumns="false" CssClass="nicetable" 
                                    Width="100%" DataSourceID="dsTranslations" 
                                    OnRowCommand="grdFindDuplicates_RowCommand" 
                                    OnPageIndexChanging="grdFindDuplicates_PageIndexChanging"
                                    PageSize="25">
                                    <PagerSettings PageButtonCount="8" Mode="NumericFirstLast" Position="TopAndBottom" />
                                    <Columns>
                                        <asp:TemplateField SortExpression="translation" HeaderText="Translation" ItemStyle-Width="80%">
                                            <ItemTemplate>
                                                <asp:Label ID="lblTranslation" runat="server" Text='<%# Eval("translation") %>' EnableViewState="False"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField SortExpression="number" HeaderText="Translations with identical text" ItemStyle-CssClass="centered">
                                            <ItemTemplate>
                                                <asp:Label ID="lblNumDuplicates" runat="server" Text='<%# Eval("number") %>' EnableViewState="False"></asp:Label>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="Details" ItemStyle-CssClass="singleButton">
                                            <ItemTemplate>
                                                <asp:UpdatePanel ID="updRadLanguage" runat="server" UpdateMode="Conditional">
                                                    <ContentTemplate>
                                                        <asp:ImageButton ID="btnViewDetails" runat="server" 
                                                            AlternateText='<%# "View Details for translation #" + Eval("translationid") %>'
                                                            ToolTip='<%# "View Details for translation #" + Eval("translationid") %>'
                                                            CommandName="viewdetails"
                                                            CommandArgument='<%# Eval("translationid") %>'
                                                            ImageUrl="~/images/upload.png" />
                                                    </ContentTemplate>
                                                    <Triggers>
                                                        <asp:PostBackTrigger ControlID="btnViewDetails" />
                                                    </Triggers>
                                                </asp:UpdatePanel>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <HeaderStyle CssClass="excelHead" />
                                    <AlternatingRowStyle CssClass="alt" />
                                </asp:GridView>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="radLanguage"
                                    EventName="SelectedIndexChanged" />
                            </Triggers>
                        </asp:UpdatePanel>
                    </div>
                </fieldset>
            </div>
        </asp:View>
        <asp:View ID="viwFindDuplicates" runat="server">
            <asp:SqlDataSource ID="dsDuplicateDetails" runat="server"
                 ConnectionString="<%$ ConnectionStrings:Default %>"
                 ProviderName="<%$ ConnectionStrings:Default.ProviderName %>">
            </asp:SqlDataSource>
            <div id="fullsizeholder" class="ssFullSize" runat="server">
                <h1><asp:Label ID="lblDUplicateTranslationsHeading" runat="server" Text="Duplicate Translations"></asp:Label></h1>
                <div class="breadcrumbs">
                    <asp:HyperLink ID="lnkNavHomeFull" runat="server" NavigateUrl="~/Default.aspx">ResourceBlender</asp:HyperLink> &gt; <asp:HyperLink ID="lnkNavTranslationsFull" runat="server" NavigateUrl="~/Translations.aspx">Translations</asp:HyperLink> &gt; <asp:LinkButton ID="lnkNavDuplicateTranslations" runat="server" OnClick="lnkNavDuplicateTranslations_Click">Duplicate Translations</asp:LinkButton> &gt; Edit Duplicate Translation
                </div>
                <div style="float:left">
                    <asp:UpdateProgress ID="upgGrdTranslations" runat="server" 
                        AssociatedUpdatePanelID="updGrdTranslations" 
                        DisplayAfter="100">
                        <ProgressTemplate>
                            <div class="centered"><asp:Image ID="imgLoadingTranslation" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Loading..." /></div>
                        </ProgressTemplate>
                    </asp:UpdateProgress>
                </div>
                <div id="inlinenav">
                    <asp:LinkButton ID="lnkExpandScreen" runat="server" CssClass="lnkContract" 
                        OnClientClick="return toggleFullWindow(this);" 
                        onclick="lnkExpandScreen_Click" CausesValidation="False" 
                        EnableViewState="False">Contract to normal size</asp:LinkButton>
                    <ul>
                        <li><a class="navApplications" id="lnkApplications" href="~/Applications.aspx" runat="server" title="Applications">Applications</a></li>
                        <li><a class="navTranslations" id="lnkTranslations" href="~/Translations.aspx" runat="server" title="Translations">Translations</a></li>
                        <li><a class="navTemplates" href="~/Templates.aspx" runat="server" title="Templates">Templates</a></li>
                        <li><a class="navGenerate" id="lnkGenerate" href="~/Generate.aspx" runat="server" title="Generate">Generate</a></li>
                        <li><a class="navImport" id="lnkImport" href="~/Import.aspx" runat="server" title="Import">Import</a></li>
                        <li><a class="navHelp" href="http://wiki.lime49.com/index.php?title=ResourceBlender" title="Help">Help</a></li>
                        <li><a class="navBackup" id="lnkBackup" href="~/Backup.aspx" runat="server" title="Backup &amp; Restore">Backup &amp; Restore</a></li>
                        <li><a class="navSettings" id="lnkSettings" href="~/Settings.aspx" runat="server" title="Settings">Settings</a></li>
                    </ul>
                </div>
                <div class="clear"></div>
                <asp:UpdatePanel ID="updGrdTranslations" runat="server" UpdateMode="Conditional">
                    <ContentTemplate>
                        <asp:GridView ID="grdDuplicateDetail" runat="server" AllowPaging="True" 
                            AllowSorting="True" AutoGenerateColumns="true" CssClass="nicetable" 
                            Width="100%"
                            OnRowDatabound="grdDuplicateDetail_RowDataBound" 
                            OnRowCommand="grdDuplicateDetail_RowCommand" 
                            OnPageIndexChanging="grdDuplicateDetail_PageIndexChanging"
                            OnSorting="grdDuplicateDetail_Sorting"
                            OnPreRender="grdDuplicateDetail_PreRender"
                            PageSize="15">
                            <PagerSettings PageButtonCount="8" Mode="NumericFirstLast" Position="TopAndBottom" />
                            <Columns>
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <%# Container.DataItemIndex +1 %>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="ssRowLabel" HorizontalAlign="Center" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="ID">
                                    <ItemTemplate>
                                        <asp:Label ID="lblTranslationId" runat="server" Text='<%# Eval("tid") %>' EnableViewState="False"></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="ssCell" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Used by" SortExpression="numelements">
                                    <ItemTemplate>
                                        <asp:Label ID="lblUsedBy" runat="server" Text='<%# Eval("numelements") + " elements" %>' EnableViewState="False" ToolTip='<%# Eval("numelements") + " elements use this translation" %>'></asp:Label>
                                        <asp:ImageButton ID="imgShowDetails" runat="server" ImageUrl="~/images/arrow_down.gif" ToolTip="Show elements" CommandName="showelements" CommandArgument="1" ></asp:ImageButton>
                                        <asp:Panel ID="pnlElementDetail" runat="server" Visible="false" CssClass="elementDetail">
                                        </asp:Panel>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="ssCell" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Edit">
                                    <ItemTemplate>
                                        <asp:MultiView ID="mltActions" runat="server" ActiveViewIndex="0">
                                            <asp:View ID="viwEdit" runat="server">
                                                <div class="centered">
                                                    <asp:ImageButton ID="btnEdit" runat="server" 
                                                        AlternateText='<%# "Edit translation #" + Eval("tid") %>' 
                                                        ToolTip='<%# "Edit translation #" + Eval("tid") %>' 
                                                        EnableViewState="False"
                                                        CommandName="edittranslation" 
                                                        ImageUrl="~/images/edit.png" />
                                                    <asp:ImageButton ID="btnDelete" runat="server" 
                                                        ToolTip='<%# "Delete translation #" + Eval("tid") %>' 
                                                        CommandName="deletetranslation" 
                                                        CommandArgument='<%# Eval("tid") %>'
                                                        ImageUrl="~/images/delete.png" />
                                                </div>
                                            </asp:View>
                                            <asp:View ID="viwSave" runat="server">
                                                <div style="max-width: 22em;">
                                                    <asp:Label ID="lblTranslationIdDesc" runat="server" Text="" EnableViewState="False" AssociatedControlID="cboTranslationID" CssClass="block"></asp:Label><%-- formatted - Reassign x elements to translation --%>
                                                    <asp:DropDownList ID="cboTranslationID" runat="server" ValidationGroup="editelement" CssClass="block">
                                                    </asp:DropDownList>
                                                    <asp:Button ID="btnChangeTranslation"  Visible="false" runat="server" Text="Change Translation" CommandName="changetranslation" EnableViewState="False" />
                                                    <asp:Label ID="lblError" runat="server" Text="" CssClass="block error"></asp:Label>
                                                    <asp:Label ID="lblTranslationComment" runat="server" Text="Comment" AssociatedControlID="txtTranslationComment" EnableViewState="False" CssClass="block"></asp:Label>
                                                    <asp:TextBox ID="txtTranslationComment" runat="server" Text='<%# Eval("translationcomment") %>' TextMode="MultiLine" EnableViewState="False" ValidationGroup="edittranslation" CssClass="block"></asp:TextBox>
                                                    <asp:Button ID="btnDeleteTranslation" runat="server" Text="Delete Translation" CommandName="deletetranslation" CommandArgument='<%# Eval("tid") %>' ValidationGroup="edittranslation" CssClass="block uniformbutton doublewidth" />
                                                    <asp:Button ID="btnSave" runat="server" Text="Save" CommandName="savetranslation" CommandArgument='<%# Eval("tid") %>' ValidationGroup="edittranslation" CssClass="uniformbutton" />
                                                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="canceledit" ValidationGroup="edittranslation" CssClass="uniformbutton" />
                                                </div>
                                            </asp:View>
                                            <asp:View ID="viwConfirmDelete" runat="server">
                                                <div class="centered">
                                                    <asp:Label ID="lblConfirmDelete" runat="server" Text='<%# "Really delete translation #"+Eval("tid") + "?" %>' CssClass="block"></asp:Label>
                                                    <asp:Button ID="btnConfirmDelete" runat="server" Text="Delete" CommandName="confirmdelete" CommandArgument='<%# Eval("tid") %>' ValidationGroup="deletetranslation" CssClass="uniformbutton" />
                                                    <asp:Button ID="btnCancelDelete" runat="server" Text="Cancel" CommandName="canceledit" ValidationGroup="deletetranslation" CssClass="uniformbutton" />
                                                </div>
                                            </asp:View>
                                        </asp:MultiView>
                                    </ItemTemplate>
                                    <ItemStyle CssClass="ssCell" />
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle CssClass="excelHead" />
                            <RowStyle CssClass="even" />
                            <AlternatingRowStyle CssClass="alt" />
                            <PagerStyle CssClass="pager" />
                            <EmptyDataTemplate>
                                <p>Invalid translation</p>
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </asp:View>
    </asp:MultiView>
</asp:Content>

